#pragma once
#include<mutex>
#include<pthread.h>



namespace Mutex
{
    class MyMutex
    {
    public:
        MyMutex()
        {
            int n = pthread_mutex_init(&lock,nullptr);
        }
        void Lock()
        {
            int n = pthread_mutex_lock(&lock);
            (void)n;
        }
        void UnLock()
        {
            int n = pthread_mutex_unlock(&lock);
            (void)n;
        }
    private:
        pthread_mutex_t lock;
    };
    class LockGuard
    {
        public:
        LockGuard(MyMutex& lock)
        :_lock(lock)
        {
            _lock.Lock();
        }
        ~LockGuard()
        {
            _lock.UnLock();
        }

        private:
        MyMutex _lock;
    };
}